package com.legendshop.openportal.sdk.model;

import cn.hutool.core.util.NumberUtil;
import io.swagger.annotations.ApiModelProperty;

/**
 * 带上分页信息的查询条件
 */
public abstract class PageRequest extends BaseRequest {
    @ApiModelProperty(value = "当前页")
    private Integer curPage = 1;

    @ApiModelProperty(value = "每页大小")
    private Integer pageSize = 100;

    public void setCurPage(Integer curPage) {
        if (curPage != null && curPage > 0) {
            this.curPage = curPage;
        } else {
            this.curPage = 1;
        }

    }

    public void setPageSize(Integer pageSize) {
        if (pageSize != null && pageSize > 0) {
            this.pageSize = NumberUtil.min(pageSize, 1000);
        } else {
            this.pageSize = 100;
        }

    }

    public Integer getCurPage() {
        return this.curPage;
    }

    public Integer getPageSize() {
        return this.pageSize;
    }
}
